﻿using System.Web.Mvc;
using WeBlog.Services;

namespace WeBlog.Controllers
{
    public class WeBlogControllerFactory : DefaultControllerFactory
    {
        public override IController CreateController(System.Web.Routing.RequestContext requestContext, string controllerName)
        {
            if (!SiteManager.IsCurrentSiteConfigured())
            {
                requestContext.RouteData.Values["action"] = "Index";
                requestContext.RouteData.Values["controller"] = "Setup";
                return base.CreateController(requestContext, "Setup");
            }

            return base.CreateController(requestContext, controllerName);
        }
    }
}